package com.tonann.app.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.tonann.common.annotation.Log;
import com.tonann.common.core.controller.BaseController;
import com.tonann.common.core.domain.AjaxResult;
import com.tonann.common.enums.BusinessType;
import com.tonann.app.domain.AppFaultHandleRecord;
import com.tonann.app.service.IAppFaultHandleRecordService;
import com.tonann.common.utils.poi.ExcelUtil;
import com.tonann.common.core.page.TableDataInfo;

/**
 * 故障处理记录Controller
 * 
 * @author tonann
 * @date 2022-10-15
 */
@RestController
@RequestMapping("/app/faultHandleRecord")
public class AppFaultHandleRecordController extends BaseController
{
    @Autowired
    private IAppFaultHandleRecordService appFaultHandleRecordService;

    /**
     * 查询故障处理记录列表
     */
    @PreAuthorize("@ss.hasPermi('app:faultHandleRecord:list')")
    @GetMapping("/list")
    public TableDataInfo list(AppFaultHandleRecord appFaultHandleRecord)
    {
        startPage();
        List<AppFaultHandleRecord> list = appFaultHandleRecordService.selectAppFaultHandleRecordList(appFaultHandleRecord);
        return getDataTable(list);
    }

    /**
     * 导出故障处理记录列表
     */
    @PreAuthorize("@ss.hasPermi('app:faultHandleRecord:export')")
    @Log(title = "故障处理记录", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, AppFaultHandleRecord appFaultHandleRecord)
    {
        List<AppFaultHandleRecord> list = appFaultHandleRecordService.selectAppFaultHandleRecordList(appFaultHandleRecord);
        ExcelUtil<AppFaultHandleRecord> util = new ExcelUtil<AppFaultHandleRecord>(AppFaultHandleRecord.class);
        util.exportExcel(response, list, "故障处理记录数据");
    }

    /**
     * 获取故障处理记录详细信息
     */
    @PreAuthorize("@ss.hasPermi('app:faultHandleRecord:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(appFaultHandleRecordService.selectAppFaultHandleRecordById(id));
    }

    /**
     * 新增故障处理记录
     */
    @PreAuthorize("@ss.hasPermi('app:faultHandleRecord:add')")
    @Log(title = "故障处理记录", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody AppFaultHandleRecord appFaultHandleRecord)
    {
        return toAjax(appFaultHandleRecordService.insertAppFaultHandleRecord(appFaultHandleRecord));
    }

    /**
     * 修改故障处理记录
     */
    @PreAuthorize("@ss.hasPermi('app:faultHandleRecord:edit')")
    @Log(title = "故障处理记录", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody AppFaultHandleRecord appFaultHandleRecord)
    {
        return toAjax(appFaultHandleRecordService.updateAppFaultHandleRecord(appFaultHandleRecord));
    }

    /**
     * 删除故障处理记录
     */
    @PreAuthorize("@ss.hasPermi('app:faultHandleRecord:remove')")
    @Log(title = "故障处理记录", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(appFaultHandleRecordService.deleteAppFaultHandleRecordByIds(ids));
    }
}
